﻿<%@ Page Language="C#" ValidateRequest="false" Trace="false" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="extractor.aspx.cs" Inherits="ExtractorPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
		
		<script>
		function validateExtractorStep1Form()
		{
			valDisplayer.hideAllValidationErrors();
			var noErrors = true;

			var pathElem = $("#<% =  PathTxt.ClientID %>");
			var extensionsElem = $("#<% = ExtensionsTxt.ClientID %>");
			var regexElem = $("#<% = RegexTxt.ClientID %>");
			if (!pathElem.val())
			{
				valDisplayer.showValidationError("Required", pathElem);
				noErrors = false;
			}
			if (!extensionsElem.val())
			{
				valDisplayer.showValidationError("Required", extensionsElem);
				noErrors = false;
			}
			if (!regexElem.val())
			{
				valDisplayer.showValidationError("Required", regexElem);
				noErrors = false;
			}			

			return noErrors;
		}

		function validateExtractorStep2Form()
		{
			valDisplayer.hideAllValidationErrors();
			var noErrors = true;

			var languageSelElem = $("#<% =  LanguageSel.ClientID %>");

			if (!languageSelElem.val())
			{
				valDisplayer.showValidationError("Required", languageSelElem);
				noErrors = false;
			}
			return noErrors;
		}				
	</script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">

	<form id="mainForm" runat="server">

		<asp:PlaceHolder runat="server" Visible="true" ID="Step1Plh">

			<h1 class="page">Extractor - Wizard Step 1/2</h1>
	
			<p>
				The extractor lets you fetch texts from a project. Texts must defined in a special format which is recognized by the regular expression. The predefined regular expression finds texts in the format seen in this example.
				<div style="margin-left: 10px;">
					<code>
						&lt;% = Txt.GetWeb("news_headline")/***<br />
						This is a major headline!<br />
						***/%&gt;
					</code>
				</div>
				<div style="margin-left: 10px; margin-top: 7px;">
					The extractor will fetch a text definition name "news_headline", and create a default text with the content "This is a major headline!".
				</div>
				
			</p>
			<p>
				None of the source files will be altered in any way by the extractor.
			</p>

			<h2 class="page">Input</h2>

			<p>
				Start by defining the criteria by which the texts is to be extracted. On the next page you will be allowed to review the texts that will be added or updated, before you decide if you want to commit them to your project file.
			</p>

			<asp:PlaceHolder runat="server" visible="false" ID="Step1ErrorPlh"><asp:Literal id="Step1ErrorLit" runat="server"></asp:Literal></asp:PlaceHolder>			

			<label>Path</label> <span class="explanatory">(folder to be crawled - e.g. c:\websites\superapp\www_app)</span><br />
			<input type="text" style="width: 450px;" value="" id="PathTxt" name="PathTxt" runat="server" /><br />
			<br />
			<label>Extensions to include <span class="explanatory">(separate with comma)</span></label><br />
			<input type="text" style="width: 450px;" value="aspx,ascx,cs" id="ExtensionsTxt" name="PathTxt" runat="server" /><br />			
			<br />
			<label>Regex to use for finding texts <span class="explanatory">(must contain named match &quot;definitionmatch&quot; and optionally &quot;defaulttextmatch&quot;)</span></label><br />
			<input type="text" style="width: 450px;" value="Txt.Get[\w]*\(\&quot;(?<definitionmatch>([\w]*))\&quot;\)(\s*/[\*]{3}(?<defaulttextmatch>(.|\s)*?)[\*]{3}/)?" id="RegexTxt" name="RegexTxt" runat="server" /><br />			
			<!--
			Txt.Get("somedefinitionname" /*[[The default value]]*/)
			Txt.Get[\w]*\(\&quot;(?<definitionmatch>([\w]*))\&quot;[^\)\[]*(\[\[(?<defaulttextmatch>(.|\n)*)\]\])?[^\)]*\)
			
			Txt.Get("somedefinitionname") /*[[The default value]]*/
			Txt.Get[\w]*\(\&quot;(?<definitionmatch>([\w]*))\&quot;\)(\s*/\*\*\*(?<defaulttextmatch>(.|\n|\s)*)\*\*\*/)?
			-->
			<div class="actionButton">			
				<button type="submit" onclick="if ( ! validateExtractorStep1Form()) { return false;	}" onserverclick="ContinueStep1Clicked" class="mainSubmit" runat="server">Continue</button>
			</div>
		
		</asp:PlaceHolder>
		<asp:PlaceHolder runat="server" Visible="false" ID="Step2Plh">
		
			<h1 class="page">Extractor - Wizard Step 2/2</h1>
			
			<p>
				Review the summary and select how you want to add the texts to the current project. Then click &quot;Commit to project file&quot; to create the texts.
			</p>
			<p>
				Once committed you will not be able to undo the changes, so always back up your project file first.
			</p>

			<h2 class="page">Criteria used for text extraction</h2>
		
			<div style="font-style: italic;margin-bottom: 5px;">Path: <asp:Literal ID="PathLit" runat="server"></asp:Literal></div>			
			<div style="font-style: italic;margin-bottom: 5px;">Extensions: <asp:Literal ID="ExtensionsLit" runat="server"></asp:Literal></div>			
			<div style="font-style: italic;margin-bottom: 5px;">Regex: <asp:Literal ID="RegexLit" runat="server"></asp:Literal></div>

			<h2 class="page">Files found</h2>
			
			<p>
				These are the texts that was found by the extractor. The texts are listed grouped by the file in which they where found.
			</p>
						
			<asp:Literal ID="FileLit" runat="server">
			</asp:Literal>
			
			<div style="font-weight: bold; font-style: italic; margin-top: 10px;">Legend:</div>
			<div style="margin-top: 3px;"><div style="width: 60px; float: left;"><i>new:</i></div> This definition did not currently exist in the project.</div>
			<div><div style="width: 60px; float: left;"><i>doublet:</i></div> This text exists in multiple location in the examined source files.</div>
			
			<h2 class="page">Settings</h2>
		
			<h3>Language</h3>		
			<p>
				Which language should the extracted default texts be saved as?
			</p>
			
			<label>Language for default texts</label><br />
			<select id="LanguageSel" name="LanguageSel" style="min-width: 200px;" runat="server"></select><br />			
			
			<div class="actionButton">
				<button id="ContinueStep2" type="submit" onclick="if ( ! validateExtractorStep2Form()) { return false;	}" onserverclick="ContinueStep2Clicked" class="mainSubmit" runat="server">Commit to project file</button>
			</div>
					
		</asp:PlaceHolder>


		<asp:PlaceHolder runat="server" Visible="false" ID="SuccessPlh">
		
			<h1 class="page">Extractor - Completed</h1>
			
			<p>
				The texts have been created and updated successfully.
			</p>
			<p>
				<a href="texts.aspx">View texts</a>
			</p>			
			
		</asp:PlaceHolder>


	</form>

</asp:Content>
